package Package.ProcessesAndThreads.Threads.SchedulingOfThreads;


public class SchedulingOfThreads {
    public static final void SchedulingOfThreads(){

//        static void sleep(long
//millis) 使当前正在执行的线程停留（暂停执行）指定的毫秒数
//void join() 等待这个线程死亡
//void setDaemon(boolean on)将此线程标记为守护线程，当运行的线程都是守护线程时，Java虚拟机 将退出
        Mythread my1=new Mythread();
        Mythread my2=new Mythread();
        Mythread my3=new Mythread();
        my1.setName("曹操");
        my2.setName("刘备");
        my3.setName("孙权");
        my1.start();
        my2.start();
        my3.start();
        Mythread my4=new Mythread();
        Mythread my5=new Mythread();
        Mythread my6=new Mythread();
        my4.setName("李渊");
        my5.setName("李世民");
        my6.setName("李元太");
        my4.start();
        try {
            my4.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        my5.start();
        my6.start();

        Mythread my7=new Mythread();
        Mythread my8=new Mythread();
        Mythread my9=new Mythread();
        my7.setName("诸葛亮");
        my8.setName("司马懿");
        my9.setName("孙策");
        my7.start();
//        设置守护线程
        my8.setDaemon(true);
        my9.setDaemon(true);
        my6.start();
        my9.start();
    }
}
